﻿Option Strict On
Option Explicit On 


Imports System.Windows.Forms

''' -----------------------------------------------------------------------------
''' Project	 : IPDataControl
''' Class	 : Core.IPDataControl.IPSimpleDecimalComboBoxManager
''' 
''' -----------------------------------------------------------------------------
''' <summary>
''' Tạo simple combobox để hiện thị ( chủ yếu với dữ liệu ít, cố định)
''' </summary>
''' <remarks>
''' </remarks>
''' <history>
''' 	[csung]	3/16/2005	Created
''' </history>
''' -----------------------------------------------------------------------------
Public Class IPSimpleDecimalComboBoxManager

#Region "CONST"
    Private Const c_display_field_name As String = "GIA_TRI"
    Private Const c_value_field_name As String = "HIEN_THI"
#End Region

#Region "MEMBER"
    Private m_cbo As ComboBox
    Private m_arl_datasource As New ArrayList
#End Region

#Region "PUBLIC"
    Public Sub New(ByVal i_combo As ComboBox)
        Me.m_cbo = i_combo
        m_cbo.DataSource = m_arl_datasource
        m_cbo.DisplayMember = c_display_field_name
        m_cbo.ValueMember = c_value_field_name
    End Sub

    Public Sub addItem(ByVal i_dc_value As Decimal, ByVal i_str_hien_thi As String)
        m_arl_datasource.Add(New SelectableItemDecimalString(i_dc_value, i_str_hien_thi))
    End Sub
#End Region


#Region "PRIVATE"

    Public Class SelectableItemDecimalString
        Private m_dc_gia_tri As Decimal
        Private m_str_hien_thi As String

        Public Sub New(ByVal i_dc_gia_tri As Decimal, ByVal i_str_hien_thi As String)
            MyBase.New()
            Me.m_dc_gia_tri = i_dc_gia_tri
            Me.m_str_hien_thi = i_str_hien_thi
        End Sub

        Public ReadOnly Property GIA_TRI() As Decimal
            Get
                Return m_dc_gia_tri
            End Get
        End Property

        Public ReadOnly Property HIEN_THI() As String
            Get
                Return m_str_hien_thi
            End Get
        End Property

        Public Overrides Function ToString() As String
            Return m_dc_gia_tri.ToString() & " - " & m_str_hien_thi
        End Function
    End Class
#End Region


End Class
